public class method2 {
    //复制数组
    //需求：定义一个方法copyOfRange（int[]arr,int from,int to)
    //功能：将数组arr中从索引from（包含from）开始。到索引to结束（不包含to）
    //的元素复制到新数组中，将数组返回
    public static void main(String[] args) {
        int[] arr={1,2,3,4,5,6,7,8,9,10};
        int[] copy=copyOfRange(arr,4,7);
        for (int j : copy) {
            System.out.print(j + " ");
        }
    }
    public static int[] copyOfRange(int[] arr,int from,int to ){
        int index=0;
        int[] newArr=new int[to-from];
        for (int i = from; i <to; i++) {
            newArr[index]=arr[i];
            index++;
        }
        return newArr;
    }
}
